﻿<UserControl 
    x:Class="FU.Capstones.IMS.Web.Silverlight.Views.MaterialOrderList"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls"
    xmlns:telerikGrid="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.GridView"
    xmlns:Navigation="clr-namespace:Navigation.Silverlight;assembly=Navigation.Silverlight"
    xmlns:Common="clr-namespace:FU.Capstones.IMS.Web.Common;assembly=FU.Capstones.IMS.Web.Common" 
    xmlns:Customs="clr-namespace:FU.Capstones.IMS.Web.Silverlight.Controls" 
    xmlns:TControls="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Data"
    Navigation:ViewModel.TypeName="FU.Capstones.IMS.Web.Silverlight.ViewModels.MaterialOrderListViewModel"
    >

    <UserControl.Resources>
    	<Common:DataContextProxy x:Key="DataContextProxy" />
    </UserControl.Resources>

    <telerik:RadBusyIndicator
        BusyContent="Đang kết nối tới máy chủ..."
        IsBusy="{Binding Path=ServiceCallCounter, Converter={StaticResource IntegerToBoolConverter}}"
        >
        <Grid x:Name="LayoutRoot" Style="{StaticResource ViewGridStyle}">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="Auto"/>
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="10"/>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="10"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="10"/>
        </Grid.RowDefinitions>

        <!--Title-->
        <Grid Grid.ColumnSpan="3">
            <Grid.Background>
                <LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
                    <GradientStop Color="{StaticResource OuterColor}" Offset="{StaticResource ControlBackgroundGradientStop0}"/>
                    <GradientStop Color="{StaticResource InnerColor}" Offset="{StaticResource ControlBackgroundGradientStop1}"/>
                    <GradientStop Color="{StaticResource InnerColor}" Offset="{StaticResource ControlBackgroundGradientStop2}"/>
                    <GradientStop Color="{StaticResource OuterColor}" Offset="{StaticResource ControlBackgroundGradientStop3}"/>
                </LinearGradientBrush>
            </Grid.Background>
            <TextBlock 
                    x:Name="lblTitle" 
                    Style="{StaticResource TextBlockTitlePageStyle}"                   
                    Text="Danh sách hóa đơn"/>
        </Grid>

        <!--Search bar-->
        <Customs:MaterialOrderSearchControl 
            Grid.Column="1" Grid.Row="2" 
            Margin="5,2"/>

        <!--Grid view-->
        <telerikGrid:RadGridView 
            x:Name="grvOrder"
            telerik:StyleManager.Theme="Office_Black"            
            Style="{StaticResource RadGridViewNormal}"
            ItemsSource="{Binding Path=OrderCollection,Mode=TwoWay}"
            Grid.Row="4" Grid.Column="1" Margin="0,2,5,0" Width="760" Height="270">
            
            <telerikGrid:RadGridView.Columns>             

                <telerikGrid:GridViewDataColumn 
                        Header="Mã Đơn Hàng"                        
                        Width="130" HeaderTextAlignment="Center">
                    <telerikGrid:GridViewDataColumn.CellTemplate>
                        <DataTemplate>
                            <HyperlinkButton 
                                    HorizontalAlignment="Right"
                                    Content="{Binding Path=OrderCode}"  
                                    Command="{Binding Path=DataSource.EditCommand, Source={StaticResource DataContextProxy}}"
                                    CommandParameter="{Binding Path=OrderID}"
                                />
                        </DataTemplate>
                    </telerikGrid:GridViewDataColumn.CellTemplate>
                </telerikGrid:GridViewDataColumn>

                <telerikGrid:GridViewDataColumn                     
                    DataMemberBinding="{Binding Path=OrderDate}"
                    Header="Ngày tạo"
                    Width="160" HeaderTextAlignment="Center"
                    TextAlignment="Right"
                />
                
                <telerikGrid:GridViewDataColumn 
                    DataMemberBinding="{Binding Path=EmployeeA.FullName}"
                    Header="Người làm"
                    Width="120" HeaderTextAlignment="Center"
                    TextAlignment="Right"
                />
                <telerikGrid:GridViewDataColumn 
                    DataMemberBinding="{Binding Path=EmployeeB.FullName}"
                    Header="Người yêu cầu"
                    Width="120" HeaderTextAlignment="Center"
                    TextAlignment="Right"
                />

                <telerikGrid:GridViewDataColumn 
                    DataMemberBinding="{Binding Path=Contact.FullName}"
                    Header="Khách hàng"
                    Width="120" HeaderTextAlignment="Center"
                    TextAlignment="Right"
                />

                <telerikGrid:GridViewColumn Width="70"  >
                    <telerikGrid:GridViewColumn.CellTemplate>
                        <DataTemplate>
                            <Grid>
                                <HyperlinkButton 
                                            HorizontalAlignment="Center"
                                            Content="{StaticResource DeleteButtonText}"    
                                            Command="{Binding Path=DataSource.DeleteCommand, Source={StaticResource DataContextProxy}}"
                                            CommandParameter="{Binding Path=OrderID}"
                                            IsEnabled="{Binding Path=DataSource.CanEditOrAdd, Source={StaticResource DataContextProxy}}"
                                            Visibility="{Binding Path=IsDeleted, Converter={StaticResource InverseBoolToVisibilityConverter}}"
                                        />
                                <TextBlock 
                                            HorizontalAlignment="Center"
								            Text="{StaticResource DeletedLabelText}"
                                            Style="{StaticResource TextBlockNormalStyle}"                                        
                                            Visibility="{Binding Path=IsDeleted, Converter={StaticResource BoolToVisibilityConverter}}"
                                        />
                            </Grid>
                        </DataTemplate>
                    </telerikGrid:GridViewColumn.CellTemplate>
                </telerikGrid:GridViewColumn>

            </telerikGrid:RadGridView.Columns>
        </telerikGrid:RadGridView>

        <!--Button-->

        <!--Button-->
        <Grid Grid.Row="5" Grid.Column="1">
            <StackPanel HorizontalAlignment="Left" Orientation="Horizontal">
                <Customs:AddButtonControl                         
                        Visibility ="{Binding Path=CanAdd, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}}"
                        />
                <Customs:ShowAllCheckBoxControl  
                        Visibility ="{Binding Path=CanEditOrAdd, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}}"                  
                        />
            </StackPanel>
            <TControls:RadDataPager
                    x:Name="DataPager1"
                    Source="{Binding Path=OrderCollection, Mode=TwoWay}"
                    Style="{StaticResource DataPagerNormalStyle}"
                    />
        </Grid>

        <!--Button-->
        <!--<Grid Grid.Row="3" Grid.Column="1">
            <Customs:AddNewShowAllButtonsControl HorizontalAlignment="Left"  />

            <TControls:RadDataPager
                    x:Name="DataPager"
                    Source="{Binding Path=OrderCollection, Mode=TwoWay}"
                    Style="{StaticResource DataPagerNormalStyle}"
                    />
        </Grid>-->

    </Grid>
    </telerik:RadBusyIndicator>
</UserControl>
